package com.css.fghs.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.css.constant.Result;
import com.css.fghs.entity.domain.FgjyXqzxXqxxbDO;
import com.css.fghs.entity.dto.XqxxReqDTO;
import com.css.fghs.entity.vo.XqxxVO;
import com.css.fghs.service.FgjyXqzxXqxxbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "需求")
@Slf4j
@RestController
@RequestMapping("/xq")
public class XqController {

    @Resource
    private FgjyXqzxXqxxbService xqService;

    @PostMapping("/getXqxx")
    @ApiOperation(value = "获取需求信息")
    public Result<Page<FgjyXqzxXqxxbDO>> getXqxx(@RequestBody XqxxReqDTO reqDTO) {
        Page<FgjyXqzxXqxxbDO> page = xqService.getXqxx(reqDTO);
        return Result.ok(page);
    }

    @PostMapping("/saveXqxx")
    @ApiOperation(value = "保存需求信息")
    public Result<String> saveXqxx(@RequestBody XqxxVO xqxxVO) {
        return Result.success(xqService.saveXqxx(xqxxVO));
    }

    @GetMapping("/getXqxxxq")
    @ApiOperation(value = "获取需求详情")
    public Result<XqxxVO> getXqxxxq(@RequestParam String xquuid) {
        return Result.success(xqService.getXqxxxq(xquuid));
    }

    @PostMapping("/updateXqzt")
    @ApiOperation(value = "修改需求状态")
    public Result<String> updateXqzt(@RequestBody XqxxVO xqxxVO) {
        return Result.success(xqService.updateXqzt(xqxxVO));
    }
}
